<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/echarts/4.2.1-rc1/echarts.js"></script>
    <script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.js"></script>
</head>
<body>
<div id="main" style="width: 600px;height:400px;"></div>
</body>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    var month=[];
    for(var i=0;i<12;i++){
        month.push((i + 1) + "月");
    }
    // 指定图表的配置项和数据
    <#include "/common/post.js"/>

    post("repairLogController.do?makeLineChart",null,function (data) {
        var t=data.thisYearData;
        var t2=data.lastYearData;
        // console.info(t,t2);
        var firstLineData=[];
        var secLineData=[];
        for(var i=0;i<12;i++){
            firstLineData.push(0);
        }
        for(var i=0;i<12;i++){
            secLineData.push(0);
        }
        for(var i=0;i<t.length;i++){
            firstLineData[t[i].m-1]=(t[i].num);
        }
        for(var i=0;i<t2.length;i++){
            secLineData[t2[i].m-1]=(t2[i].num);
        }
        var option = {
            xAxis: {
                type: 'category',
                data:month,
            },
            legend: {
                data:['今年','去年'],
            },
            yAxis: {
                type: 'value'
            },
            tooltip : {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    label: {
                        backgroundColor: '#6a7985'
                    }
                }
            },
            series: [
                {
                name:"今年",
                data: firstLineData,
                type: 'line',
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                    }
                },
            },
                {
                name:"去年",
                data: secLineData,
                type: 'line',
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                    }
                },
            },
            ]
        };


        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    });


</script>
</html>